#ifndef _RDA5807M_H
#define _RDA5807M_H
#include "system_cw32l010.h"
#define I2C1_SCL_GPIO_PIN GPIO_PIN_1
#define I2C1_SDA_GPIO_PIN GPIO_PIN_0

typedef struct{
    unsigned char mode;
    unsigned char step;//步进设置 0 200; 1 100；2 50; 3;25
    unsigned short chip_id;
    unsigned char rssi;
    unsigned char search_flag;
    float freq;
    unsigned char vol;
    float battery;
    unsigned short RDA5807_REG_02;
    unsigned short RDA5807_REG_03;
    unsigned short RDA5807_REG_05;

}fm_t;

extern fm_t fm_info;
#define RDA5807_WR_ADDRESS  0x22       ///<RDA5807 写地址
#define RDA5807_RD_ADDRESS  0x23       ///<RDA5807 读地址
//02H SYSTEM 
#define MUTE_ON ~(1<<14) //静音开
#define MUTE_OFF 1<<14 //静音关闭
#define MONO_STERE ~(1<<13) //双声道
#define MONO_FOREC 1<<13 //单声道
#define BASS_OFF ~(1<<12) //关闭低音增强
#define BASS_ON 1<<12 //开启低音增强
#define RDS_EN 1<<3 //RDS启动



void FM_GPIO_INIT(void);
void FM_I2C_INIT(void);
void FM_READ_CHIP(void);
void RDA5807M_Init(void);
void RDA5807M_SetVolume(unsigned char val);
void RDA5807M_Search_Freq_TurnUp(void);
void RDA5807M_Search_Freq_TurnDown(void);
void FM_GET_INFO(void);

void RDA5807M_Bass(uint8_t ctl);
void RDA5807M_Mono(uint8_t ctl);
void RDA5807M_band(uint8_t ctl);
void RDA5807M_Step(uint8_t ctl);
void RDA5807M_SeekMode(uint8_t ctl);
void RDA5807M_LnaMode(uint8_t ctl);
void RDA5807M_LnaCurrent(uint8_t ctl);
void RDA5807M_SeekTH(uint8_t th);

#endif // !_RDA5807M_H